package top.lyjwn.todo.weinxin;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import top.lyjwn.todo.weinxin.param.WXAppletParam;

/**
 * 微信小程序配置
 *
 * @author luoyujie
 */
@Configuration
public class WXAppletConfig implements EnvironmentAware {

    private Environment environment;

    @Override
    public void setEnvironment(Environment environment) {
        this.environment = environment;
    }

    @Bean
    public WXAppletParam getWXAppletParam()
    {
        WXAppletParam wxAppletParam = new WXAppletParam();
        String appid = this.environment.getProperty("lyjwn.weinxin.applet.appid");
        wxAppletParam.setAppid(appid);
        String appsecret = this.environment.getProperty("lyjwn.weinxin.applet.appsecret");
        wxAppletParam.setAppsecret(appsecret);
        String domain_name = this.environment.getProperty("lyjwn.weinxin.applet.domain-name");
        wxAppletParam.setDomainName(domain_name);
        String auth_domain_name = this.environment.getProperty("lyjwn.weinxin.applet.auth-domain-name");
        wxAppletParam.setAuthDomainName(auth_domain_name);
        return  wxAppletParam;
    }

    /*


    @Value("${top.lyjwn.todo.weinxin.applet.appid}")
    public void setAPPID(String APPID) {
        WXAppletConfig.APPID = APPID;
    }

    @Value("${top.lyjwn.todo.weinxin.applet.appsecret}")
    public void setAPPSECRET(String APPSECRET) {
        WXAppletConfig.APPSECRET = APPSECRET;
    }

    @Value("${top.lyjwn.todo.weinxin.applet.domain_name}")
    public void setDomainName(String domainName) {
        DOMAIN_NAME = domainName;
    }

    @Value("${top.lyjwn.todo.weinxin.applet.auth_domain_name}")
    public void setAuthDomainName(String authDomainName) {
        AUTH_DOMAIN_NAME = authDomainName;
    }
    */
}
